<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>设备管理</title>
    <#include "../../common/link.ftl">
    <script>
           $(function () {
               // 归还申请
               $(".leadBtn").click(function () {
                   var hot = $(this).data("hot");
                   var id = $(this).data("id");
                   $.get("/deviceRecord/applyReturn.do", {hot:hot, id:id}, function (data) {
                       if(data.code == 200){
                           window.location.reload();
                       }else{
                           $.messager.alert("温馨提示", data.msg);
                       }
                   })
               });

               // 查看申请理由
               $(".reasonBtn").click(function () {
                   //数据复原
                   $("#editForm").clearForm(true);

                   var json = $(this).data('json');
                   if(json){
                       $("textarea[name='reason']").val(json.reason);
                   }
                   $("#inputSynModal").modal('show');
               });


           })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../../common/navbarAsso.ftl">
    <!--菜单回显-->
    <#assign currentMenu="list"/>
    <#include "../../common/menuAsso.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>设备借还记录</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 10px;">
                    <form class="form-inline" id="searchForm" action="/deviceRecord/association/list.do" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label for="keyword">关键字：</label>
                            <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}" placeholder="请输入设备名称/负责人">
                        </div>
                        &nbsp;
                        <div class="form-group">
                            <label for="leadStatus"> 借出：</label>
                            <select class="form-control" id="leadStatus" name="leadStatus">
                                <option value="-1">全部</option>
                                <option value="0">申请中</option>
                                <option value="1">借用成功</option>
                                <option value="2">借用失败</option>
                            </select>
                            <script>
                                $("#leadStatus").val(${qo.leadStatus!});
                            </script>
                        </div>
                        &nbsp;
                        <div class="form-group">
                            <label for="returnStatus"> 归还：</label>
                            <select class="form-control" id="returnStatus" name="returnStatus">
                                <option value="-1">全部</option>
                                <option value="0">申请中</option>
                                <option value="1">已归还</option>
                                <option value="2">未归还</option>
                            </select>
                            <script>
                              $("#returnStatus").val(${qo.returnStatus!});
                            </script>
                        </div>
                        &nbsp;
                        <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                    </form>
                </div>
                <table class="table table-hover table-bordered">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>设备名称</th>
                        <th>借用数量</th>
                        <th>负责人</th>
                        <th>联系方式</th>
                        <th>申请时间</th>
                        <th>申请理由</th>
                        <th>借用状态</th>
                        <th>借出时间</th>
                        <th>归还状态</th>
                        <th>归还时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                  <#list page.list as deviceRecord>
                        <tr>
                            <td>${deviceRecord_index+1}</td>
                            <td>${deviceRecord.deviceName!}</td>
                            <td>${deviceRecord.number!}</td>
                            <td>${(deviceRecord.dutyName)!}</td>
                            <td>${(deviceRecord.mobile)!}</td>
                            <td>${(deviceRecord.applyTime?string('yyyy-MM-dd HH:mm:ss'))!}</td>
                            <td>
                                <a class="reasonBtn" href="JavaScript:;" data-json='${deviceRecord.jsonString!}'>申请理由
                                </a>
                            </td>

                            <td>
                                <#if (deviceRecord.isAgree!) == 0>
                                    申请中
                                </#if>
                                <#if (deviceRecord.isAgree!) == 1>
                                    成功
                                </#if>
                                <#if (deviceRecord.isAgree!) == 2>
                                    失败
                                </#if>
                            </td>
                            <td>${(deviceRecord.lendingTime?string('yyyy-MM-dd'))!}</td>
                            <td>
                                <#if (deviceRecord.isReturn!) == 0>
                                    申请中
                                </#if>
                                <#if (deviceRecord.isReturn!) == 1>
                                    成功
                                </#if>
                                <#if (deviceRecord.isReturn!) == 2>
                                    失败
                                </#if>
                            </td>
                            <td>${(deviceRecord.returnTime?string('yyyy-MM-dd HH:mm:ss'))!}</td>
                            <td>
                                <#if (deviceRecord.isAgree!) == 1 && (deviceRecord.isReturn!) != 1 && (deviceRecord.isReturn!) != 0>
                                    <a class="btn btn-success btn-xs leadBtn" href="javascript:;" data-id='${deviceRecord.id}' data-hot="0">
                                        <span class="glyphicon glyphicon-minus-sign"></span> 申请归还
                                    </a>
                                </#if>
                                <#if (deviceRecord.isAgree!) == 1 && (deviceRecord.isReturn!) == 0>
                                    <a class="btn btn-primary btn-xs" href="javascript:;">
                                        <span class="glyphicon glyphicon-time"></span> 归还中
                                    </a>
                                </#if>
                            </td>
                        </tr>
                  </#list>
                </table>
                <!--分页-->
                <#include "../../common/page.ftl">
            </div>
        </section>
    </div>
    <#include "../../common/footer.ftl">
</div>

<!-- Modal模态框 -->
<div class="modal fade" id="inputSynModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalSynLabel">申请理由</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="" method="post" id="editForm">
                    <div class="form-group">
                        <div class="col-sm-12">
                            <textarea rows="10" style="min-width: 100%" name="reason"></textarea>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

</body>
</html>
